package en.edu.scau.cmi.zhanzhiyong.carpter10;

import java.io.*;

public class Example10_8 {

	public static void main(String args[]) {
		RandomAccessFile inAndOut = null;
		
		int data[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		File file = new File("F:/tom.dat");
		
		try {
			inAndOut = new RandomAccessFile(file, "rw");
			
			for(int i = 0;i < data.length; i++) {
				inAndOut.writeInt(data[i]);
			}
			
			for(long i = data.length-1;i >= 0;i--) {
				inAndOut.seek(i*4);
				System.out.printf("\t%d",inAndOut.readInt());
				
			}
		}
		catch(Exception e) {
			System.out.println(e);
		}
	}
}
